package cn.wuxing.mediation.system.service.impl;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import cn.wuxing.mediation.common.utils.DateUtils;
import cn.wuxing.mediation.system.service.ISTownshipCenterService;
import org.springframework.stereotype.Service;
import cn.wuxing.mediation.system.mapper.TownshipCenterMapper;
import cn.wuxing.mediation.system.domain.TownshipCenter;

import javax.annotation.Resource;

/**
 * 乡镇治理中心Service业务层处理
 *
 * @author mediation
 * @date 2024-10-10
 */
@Service
public class ISTownshipCenterServiceImpl implements ISTownshipCenterService
{
    @Resource
    private TownshipCenterMapper townshipCenterMapper;

    /**
     * 查询乡镇治理中心
     *
     * @param id 乡镇治理中心主键
     * @return 乡镇治理中心
     */
    @Override
    public TownshipCenter selectTownshipCenterById(Long id)
    {
        return townshipCenterMapper.selectTownshipCenterById(id);
    }

    /**
     * 查询乡镇治理中心列表
     *
     * @param townshipCenter 乡镇治理中心
     * @return 乡镇治理中心
     */
    @Override
    public List<TownshipCenter> selectTownshipCenterList(TownshipCenter townshipCenter)
    {
        return townshipCenterMapper.selectTownshipCenterList(townshipCenter);
    }

    /**
     * 新增乡镇治理中心
     *
     * @param townshipCenter 乡镇治理中心
     * @return 结果
     */
    @Override
    public int insertTownshipCenter(TownshipCenter townshipCenter)
    {
        townshipCenter.setCreateTime(DateUtils.getNowDate());
        return townshipCenterMapper.insertTownshipCenter(townshipCenter);
    }

    /**
     * 修改乡镇治理中心
     *
     * @param townshipCenter 乡镇治理中心
     * @return 结果
     */
    @Override
    public int updateTownshipCenter(TownshipCenter townshipCenter)
    {
        townshipCenter.setUpdateTime(DateUtils.getNowDate());
        return townshipCenterMapper.updateTownshipCenter(townshipCenter);
    }

    /**
     * 批量删除乡镇治理中心
     *
     * @param ids 需要删除的乡镇治理中心主键
     * @return 结果
     */
    @Override
    public int deleteTownshipCenterByIds(Long[] ids)
    {
        return townshipCenterMapper.deleteTownshipCenterByIds(ids);
    }

    /**
     * 删除乡镇治理中心信息
     *
     * @param id 乡镇治理中心主键
     * @return 结果
     */
    @Override
    public int deleteTownshipCenterById(Long id)
    {
        return townshipCenterMapper.deleteTownshipCenterById(id);
    }

    @Override
    public List<Object> getTownshipCenterAll(String townshipName) {
        List<Object> dataResult=new ArrayList<>();
        List<Map<String,Object>> townshipCenterAll=townshipCenterMapper.getTownshipCenterAll(townshipName);
        dataResult.addAll(townshipCenterAll);
        return dataResult;
    }
}
